package com.offcn.sellergood.file;

import org.csource.common.MyException;
import org.csource.fastdfs.*;

import java.io.IOException;

public class TestFastDFS {
    public static void main(String[] args) throws MyException, IOException {
        // 0.获取全局的配置文件
        ClientGlobal.init("D:\\MyCodes\\JavaMicroService\\day10_dongyimai\\dongyimai-parent\\dongyimai-service\\dongyimai-file-service\\src\\main\\resources\\fdfs_client.conf");
        // 1.创建 TrackerClient
        TrackerClient trackerClient = new TrackerClient();
        // 2.通过 TrackerClient 创建 TrackerServer
        TrackerServer trackerServer = trackerClient.getConnection();
        // 3.创建 StorageServer 不需要指定，直接指定为 null
        StorageServer storageServer = null;
        // 4.根据 TrackerServer 和 StorageServer 创建 StorageClient
        StorageClient storageClient = new StorageClient(trackerServer, storageServer);
        // 5.通过StorageClient 实现文件上传
        String[] strings = storageClient.upload_file("C:\\Users\\32990\\Desktop\\111353d8lre0sel5leqe5g.jpg", "jpg", null);
        for (String string : strings) {
            System.out.println(string);
            // http://192.168.80.128:8080/group1/M00/00/00/wKhQgGE3iJKAZZ5QACj1bL0wUkA450.jpg
        }

    }
}
